<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>搜索页面</title>
<link href="../static/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="../static/css/admin.css" rel="stylesheet" type="text/css" />
<link href="../static/css/demo.css" rel="stylesheet" type="text/css" />
<link href="../static/css/seastyle.css" rel="stylesheet" type="text/css" />
<script src="../static/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="../static/js/script.js"></script>
<script src="../static/js/myinit.js"></script>
</head>

<body>

<!--顶部导航条 -->
<div class="am-container header">
  <ul class="message-l">
    <div class="topMessage">
      <div class="menu-hd"> <a href="#" target="_top" class="h">亲，请登录</a> <a href="#" target="_top">免费注册</a> </div>
    </div>
  </ul>
  <ul class="message-r">
    <div class="topMessage home">
      <div class="menu-hd"><a href="#" target="_top" class="h">商城首页</a></div>
    </div>
    <div class="topMessage my-shangcheng">
      <div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
    </div>
    <div class="topMessage mini-cart">
      <div class="menu-hd"><a id="mc-menu-hd" href="#" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
    </div>
       <div class="topMessage favorite">
            <div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
          </div>
        </ul>
      </div>

<!--悬浮搜索框-->

<div class="nav white"  data-role="page" id="home">
  <div class="logo"><img src="../static/img/logo.png" /></div>
  <div class="logoBig">
    <li><img src="../static/img/logobig.png" /></li>
  </div>
  <div class="search-bar pr"> <a name="index_none_header_sysc" href="#"></a>
    <form>
        <input id="searchInput" type="text" placeholder="搜索" />
        <input id="ai-topsearch" class="submit am-btn" value="搜索" />
      </form>
  </div>
</div>
<div class="clear"></div>
<b class="line"></b>
<div class="search">
  <div class="search-list">
    <div class="nav-table">
      <div class="long-title"><span class="all-goods">全部分类</span></div>
      <div class="nav-cont">
        <ul>
          <li class="index"><a href="#">首页</a></li>
          <li class="qc"><a href="#">闪购</a></li>
          <li class="qc"><a href="#">限时抢</a></li>
          <li class="qc"><a href="#">团购</a></li>
          <li class="qc last"><a href="#">大包装</a></li>
        </ul>
        <div class="nav-extra"> <i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的优惠券<i class="am-icon-angle-right" style="padding-left: 10px;"></i> </div>
      </div>
    </div>
    <div class="am-g am-g-fixed">
      <div class="am-u-sm-12 am-u-md-12">
        <div class="theme-popover">
          <div class="searchAbout"> <span class="font-pale">相关搜索：</span> <a title="坚果" href="#">坚果</a> <a title="瓜子" href="#">瓜子</a> <a title="鸡腿" href="#">豆干</a> </div>
          <ul class="select">
            <p class="title font-normal"> <span class="fl">松子</span> <span class="total fl">搜索到<strong class="num">997</strong>件相关商品</span> </p>
            <div class="clear"></div>
            <li class="select-result">
              <dl>
                <dt>已选</dt>
                <dd class="select-no"></dd>
                <p class="eliminateCriteria">清除</p>
              </dl>
            </li>
            <div class="clear"></div>
            <li class="select-list">
              <dl id="select1">
                <dt class="am-badge am-round">品牌</dt>
                <div class="dd-conent" id="pinpaifenlei">
                  
                </div>
              </dl>
            </li>
          </ul>
          <div class="clear"></div>
        </div>
        <div class="search-content">
          <div class="sort">
            <li class="first"><a title="综合">综合排序</a></li>
            <li><a title="销量" id="xiaoliangpx">销量排序</a></li>
            <li><a title="价格" id="jiagepx">价格优先</a></li>
          </div>
          <div class="clear"></div>
          <ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes" id="sousuojieguo">
            
          </ul>
        </div>
        <div class="search-side">
          <div class="side-title"> 经典搭配 </div>
          <li>
            <div class="i-pic check"> <img src="../static/img/cp.jpg" />
              <p class="check-title">萨拉米 1+1小鸡腿</p>
              <p class="price fl"> <b>¥</b> <strong>29.90</strong> </p>
              <p class="number fl"> 销量<span>1110</span> </p>
            </div>
          </li>
          <li>
            <div class="i-pic check"> <img src="../static/img/cp2.jpg" />
              <p class="check-title">ZEK 原味海苔</p>
              <p class="price fl"> <b>¥</b> <strong>8.90</strong> </p>
              <p class="number fl"> 销量<span>1110</span> </p>
            </div>
          </li>
          <li>
            <div class="i-pic check"> <img src="../static/img/cp.jpg" />
              <p class="check-title">萨拉米 1+1小鸡腿</p>
              <p class="price fl"> <b>¥</b> <strong>29.90</strong> </p>
              <p class="number fl"> 销量<span>1110</span> </p>
            </div>
          </li>
        </div>
        <div class="clear"></div>
        <!--分页 -->
        <ul class="am-pagination am-pagination-right">
          <li class="am-disabled"><a href="#">&laquo;</a></li>
          <li class="am-active"><a href="#">1</a></li>
          <li><a href="#">2</a></li>
          <li><a href="#">3</a></li>
          <li><a href="#">4</a></li>
          <li><a href="#">5</a></li>
          <li><a href="#">&raquo;</a></li>
        </ul>
      </div>
    </div>
    <div class="footer ">
      <div class="footer-hd">
        <p><img src="../static/img/duo.png" style="width:25px" />品类齐全<b>|</b><img src="../static/img/kuai.png" style="width:25px" />多仓直发<b>|</b><img src="../static/img/hao.png" style="width:25px" />正品行货<b>|</b><img src="../static/img/sheng.png" style="width:25px" />天天低价</p>
      </div>
      <div class="footer-bd "> </div>
    </div>
  </div>
</div>

<!--引导 -->
<div class="navCir">
  <li><a href="home.html"><i class="am-icon-home "></i>首页</a></li>
  <li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
  <li><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>
  <li><a href="person/index.html"><i class="am-icon-user"></i>我的</a></li>
</div>

<!--菜单 -->
<div class=tip>
  <div id="sidebar">
    <div id="wrap">
      <div id="prof" class="item "> <a href="# "> <span class="setting "></span> </a>
        <div class="ibar_login_box status_login ">
          <div class="avatar_box ">
            <p class="avatar_imgbox "><img src="../static/img/no-img_mid_.jpg " /></p>
            <ul class="user_info ">
              <li>用户名sl1903</li>
              <li>级&nbsp;别普通会员</li>
            </ul>
          </div>
          <div class="login_btnbox "> <a href="# " class="login_order ">我的订单</a> <a href="# " class="login_favorite ">我的收藏</a> </div>
          <i class="icon_arrow_white "></i> </div>
      </div>
      <div id="shopCart " class="item "> <a href="# "> <span class="message "></span> </a>
        <p> 购物车 </p>
        <p class="cart_num ">0</p>
      </div>
      <div id="brand " class="item "> <a href="#"> <span class="wdsc "><img src="../static/img/wdsc.png " /></span> </a>
        <div class="mp_tooltip "> 我的收藏 <i class="icon_arrow_right_black "></i> </div>
      </div>
      <div id="broadcast " class="item "> <a href="# "> <span class="chongzhi "><img src="../static/img/chongzhi.png " /></span> </a>
        <div class="mp_tooltip "> 我的充值 <i class="icon_arrow_right_black "></i> </div>
      </div>
      <div class="quick_toggle ">
        <li class="qtitem "> <a href="# "><span class="kfzx "></span></a>
          <div class="mp_tooltip ">客服在线<i class="icon_arrow_right_black "></i></div>
        </li>
        <!--二维码 -->
        <li class="qtitem "> <a href="#none "><span class="mpbtn_qrcode "></span></a>
          <div class="mp_qrcode " style="display:none; "><img src="../static/img/weixin_code_145.png "/><i class="icon_arrow_white "></i></div>
        </li>
        <li class="qtitem "> <a href="#top " class="return_top "><span class="top "></span></a> </li>
      </div>
      
      <!--回到顶部 -->
      <div id="quick_links_pop" class="quick_links_pop hide"></div>
    </div>
  </div>
</div>
<script type="text/javascript">
	var openid =getUrldata("OPENID");
	var keywords=getUrldata('KEYWORD');
/*
	$(document).on('pagebeforeshow','#home',function(){
		var ww=$(document).innerWidth();
		$('#home .ui-header .ui-input-text').addClass('myserch');
		$('#home .ui-header .ui-input-text').css('width',ww-100+"px");
		$('#home .ui-header .ui-input-text input').css('width',ww-125+"px");
		$('#home .ui-header .ui-input-text input').css('margin-left',25+"px");
	 	//initBanner(277/640);
	});

	$('#tocagagory').click(function(e) {
		if($('#cagatorylist').find('li').length==0){
			initcagatory();
		}else{
			if($('#cagatorylist').hasClass('mypannelshow')){
				$('#cagatorylist').removeClass('mypannelshow');
				$('#cagatorylist').addClass('mypannelhide');
			}else{
				$('#cagatorylist').addClass('mypannelshow');
				$('#cagatorylist').removeClass('mypannelhide');
		
			}
			$('#cagatorylist').show();
		}
		 
	});
	
	function initcagatory(){
		var url = "/webserver/api/v1/catagory/?format=json";
		$.getJSON(url,function(rs){
			var objects=rs.objects;
			$.each(objects,function(index,item){
				$('#cagatorylist').append('<li  id="'+item.id+'">'+item.name+'</li>');
			});
			$('#cagatorylist').listview('refresh');
			$('#cagatorylist li').click(function(e) {
				var id = $(this).attr('id');
				var htm =$(this).html();
				window.location.href="list_by_caga.html?CAGAID="+id+"&HTM="+htm+"&OPENID="+openid;
			});
			
			 
			if($('#cagatorylist').hasClass('mypannelshow')){
				$('#cagatorylist').removeClass('mypannelshow');
				$('#cagatorylist').addClass('mypannelhide');
			}else{
				$('#cagatorylist').addClass('mypannelshow');
				$('#cagatorylist').removeClass('mypannelhide');
		
			}
			$('#cagatorylist').show();
		});
		
	
	}
	
	function refreshCartTotal(){
		var num=cartHelper.getCart().count;
		if(num>0){
			$('#cart_total').html(num);
			$('#cart_total').show();
		}else{
			$('#cart_total').hide();
		}
	}
	
	 
	
	$('#toindex').click(function(){
		document.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1ef1259eec8b148d&redirect_uri=http%3a%2f%2fwww.tiantianhw.cn%2fmshop%2findex.html&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
	});
	
	$('#toshoppindlist').click(function(){
		window.location.href="shoppinglist.html?OPENID="+openid;
	});
	
	
	 
	
	$('#towode').click(function(){
		document.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1ef1259eec8b148d&redirect_uri=http%3a%2f%2fwww.tiantianhw.cn%2fmshop%2fhuiyuanshouye.html&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
	});
	
	
	$('#totop').click(function(){
		$('html,body').animate({scrollTop: '0px'}, 800);
	});
	
	
	
	 
	function toUrl(url){
		document.location.href=url;
	}
	
	$(document).scroll(function(){
		var scroll_top = $(document).scrollTop();
		var touming = 1;
		if(scroll_top<320){
			touming=scroll_top*1.0/320;
		}
		
		$('#to_top').stop().fadeTo('fast',touming)
		
		
	
	});
	
	$('#to_top').click(function(){
		$('html,body').animate({scrollTop: '0px'}, 800);
	});
	*/
	
	
	
	$('#ai-topsearch').click(function(e) {
        var htm=$('#searchInput').val();
		if(htm!=''){
			document.location.href="search_pc.html?OPENID="+openid+"&KEYWORD="+htm;
		}
	});

	/***************本页逻辑开始********************/
	
$(document).ready(function(){
	sousuo();
	paixu();
});
function paixu(){
	var xiaoliang=0;
	var jiage=0;
	$('#xiaoliangpx').click(function(e){
		if(xiaoliang==0){
			xiaoliang=1;
		}else{
			xiaoliang=0;
		}
		if(xiaoliang==0){
			var url = "/webserver/api/v1/good_sale2/?format=json&name__contains="+keywords;
			$.getJSON(url,function(rs){
				console.log(rs);
				var objects = rs.objects;
				$('#sousuojieguo').empty();
				$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
				});
			});
		}else{
			var url = "/webserver/api/v1/good_sale1/?format=json&name__contains="+keywords;
			$.getJSON(url,function(rs){
				console.log(rs);
				var objects = rs.objects;
				$('#sousuojieguo').empty();
				$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
				});
			});
		}
		$('#sousuojieguo').show();
	});
	
	
	$('#jiagepx').click(function(e){
		if(jiage==0){
			jiage=1;
		}else{
			jiage=0;
		}
		if(jiage==0){
			var url = "/webserver/api/v1/good_price2/?format=json&name__contains="+keywords;
			$.getJSON(url,function(rs){
				console.log(rs);
				var objects = rs.objects;
				$('#sousuojieguo').empty();
				$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
				});
			});
		}else{
			var url = "/webserver/api/v1/good_price1/?format=json&name__contains="+keywords;
			$.getJSON(url,function(rs){
				console.log(rs);
				var objects = rs.objects;
				$('#sousuojieguo').empty();
				$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
				});
			});
		}
		$('#sousuojieguo').show();
	});
}
	
	function sousuo(){
		var url = "/webserver/api/v1/good/?format=json&name__contains="+keywords;
		var ww=$(document).innerWidth();
		$.getJSON(url,function(rs){
			console.log(rs);
			var objects = rs.objects;
			$.each(objects,function(index,item){
				$('#pinpaifenlei').append('<dd><a id="'+item.id+'">'+item.brand.name+'</a></dd>'); 
				$('#'+item.id+'').click(function(e){
					$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
					});
				});
				$('#sousuojieguo').show();
				/*.
				var iscontai=0;
				var aaa=$('#pinpaifenlei').find('a');
				$.each(aaa,function(i,element){
					if($(this).html()==item.brand.name){
						iscontai++;
					}
				});
				if(iscontai==0){
					$('#pinpaifenlei').append('<dd onclick="toUrl(\'search_pc.html?GOODID='+item.brand.name+'&OPENID='+openid+'\'><a href="#">'+item.brand.name+'</a></dd>');
				}*/
			});
			if(objects.length!=0){
				$('#sousuojieguo').empty();
				$.each(objects,function(index,item){
					$('#sousuojieguo').append('<li onclick="toUrl(\'introduction_pc.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="i-pic limit"> <img src="'+item.image_thumb+'"  width="218" height="218"  /><p class="title fl">'+item.name+'</p><p class="price fl"> <b>¥</b> <strong>'+item.price+'</strong> </p><p class="number fl"> 销量<span>'+item.sales+'</span> </p></div></li>');
				});
			}
			$('#sousuojieguo').show();
		},'json');
		
		$.getJSON(url,function(rs){
			var objects = rs.objects;
		});
	}

</script>
</body>
</html>